package agent;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;

import java.io.IOException;

/**
 * @author xuewenke
 * @since 2022/10/12 12:01 AM
 */
public class AttachJVM {

    public static void main(String[] args) throws IOException, AttachNotSupportedException, AgentLoadException, AgentInitializationException {

        // -javaagent:/Users/xuewenke/workspace/arts/seventools/agent/target/agent-1.0-SNAPSHOT.jar

        VirtualMachine virtualMachine =  VirtualMachine.attach("46206");
        virtualMachine.loadAgent("/Users/xuewenke/Desktop/agent-1.0-SNAPSHOT-jar-with-dependencies.jar");
//        virtualMachine.loadAgent("-javaagent:/Users/xuewenke/Desktop/agent-1.0-SNAPSHOT-jar-with-dependencies.jar");

    }
}